﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
//using System.Web.DynamicData;
using OA.Model;
using OA.Model.MyAttribute;
using OA.Core;


namespace OA.Model
{
    [Table("Department")]
    public class Department : BaseInfo
    {
        public int Status { get; set; }

        [Display(Name ="名称")]
        [Tag(TagEnum.Text, "required", "名称", 2, 50)]
        [MaxLength(50)]
        public string Name { get; set; }
        

        [NotMapped]
        public string FullName { get; set; }

        [Display(Name = "上级部门")]
       // [Index("ParentDepartmentID")]
        public int ParentDepartmentID { get; set; }

        /// <summary>
        /// 部门负责岗位
        /// </summary>
        [Display(Name= "领导岗位")]
        [Tag(TagEnum.Text, "required", "部门负责岗位", 2, 50)]
        public int LeaderPositionID { get; set; }

        /// <summary>
        /// 部门负责岗位
        /// </summary>
        [Display(Name = "领导岗位2")]
        [Tag(TagEnum.Text, "", "部门负责岗位", 2, 50)]
        public int? LeaderPositionID2 { get; set; }


        [Display(Name = "排序")]
        [Tag(TagEnum.Number, "required", "排序", 2, 50)]
        public int Sort { get; set; }

        public virtual ICollection<Position> Positions { get; set; }

    }

    public class SimpleDepartment : SimpleInfo
    {
        public string Name { get; set; }

        public string FullName { get; set; }

        public int Sort { get; set; }

        public int ParentDepartmentID { get; set; }        

        public string LeaderEmpID { get; set; }

        public string LeaderEmpName { get; set; }



        public int LeaderPositionID { get; set; }

        public static Expression<Func<Department, SimpleDepartment>> Map = m => new SimpleDepartment() { ID = m.ID, Name = m.Name, Sort = m.Sort, Status = m.Status, ParentDepartmentID = m.ParentDepartmentID, LeaderPositionID = m.LeaderPositionID };

    }

    public class SimpleDepartment2 : SimpleInfo
    {
        public string Name { get; set; }

        public string FullName { get; set; }

        public int ParentDepartmentID { get; set; }
        
    }
}
